# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-modbus-tk
pkgname=('python2-modbus-tk' 'python-modbus-tk')
_pkgname=modbus_tk
pkgver=1.1.5
pkgrel=1
epoch=1
pkgdesc='Implementation of modbus protocol in Python.'
url='https://pypi.org/project/modbus_tk/#files'
license=('LGPL')
arch=('any')
provides=('modbus-tk' 'python2-modbus-tk' 'python-modbus-tk')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/modbus_tk-$pkgver.tar.gz")
sha512sums=('da5862ca72dda3942c0dc059bc9b08a9de65290e11292f4c6aa430a0027a60cced664e4fe12d60a19593cb6cdccf99de97317c53627b39e7524e351fd3ec1ce2')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-modbus-tk() {
  depends=('python2' 'python2-pyserial')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

package_python-modbus-tk() {
  depends=('python' 'python-pyserial')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

